package chessGame.piece;

/**
 * @BelongsProject: chessGame
 * @BelongsPackage: chessGame
 * @CreateTime: 2025-09-30  09:15
 * @Description: TODO
 * @Version: 1.0
 */

import java.util.*;

import chessGame.Board;
import chessGame.annotation.PieceInfo;
import chessGame.utils.MoveUtils;
import chessLib.KnightMove;
import chessLib.Position;

@PieceInfo(value = "Knight")
public class Knight extends Piece{

    private final KnightMove knightMove;
    public Knight() {
        super("Knight");
        this.knightMove = new KnightMove();
    }

    public Knight(String pieceName) {
        super(pieceName);
        this.knightMove = new KnightMove();
    }


    @Override
    public Set<Position> getValidMoves(Position currentPosition, Board board) {
        // 从ChessLib获取移动的位置
        Collection<Position> libMoves = knightMove.validMovesFor(currentPosition);
        // 过滤掉已经占用的位置
        return MoveUtils.deduplication(libMoves, board);


    }


    @Override
    public String getName() {
        return "Knight";
    }


}
